package com.yuantu.judiciary.dao;

import com.yuantu.judiciary.model.domain.SysOperLogDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.sql.Timestamp;
import java.util.List;

/**
 * 操作日志
 *
 * @author syw
 * @since 2023-08-15
 **/
public interface ISysOperLogDao extends JpaRepository<SysOperLogDO, Long> {

    SysOperLogDO findFirstByCreatorIdInAndDeletedFalseOrderByIdDesc(List<Long> creatorId);

    @Transactional
    @Modifying
    @Query(value = "delete from sys_oper_log where create_time < :createTime ", nativeQuery = true)
    void removeByCreateTimeBefore(Timestamp createTime);
}
